function im = board_position(row,col)

    % Load Image 读取图片
    im = imread('chess.png');
    
    % Obtain the size of the image 获取图像的大小
    [rows, columns] = size(im);
    
    % Calculate the board size 计算棋盘的大小(正方形)
    board_size = rows/8;
    
    % Calculate the require position 计算目标的位置
    row_start = row * board_size + 1;
    col_start = col * board_size + 1;
    
    row_end = row_start + board_size - 1;
    col_end = col_start + board_size - 1;
    
    % 剪切图像
    im_crop = im(row_start : row_end,col_start:col_end,:);
    im_gray = rgb2gray(im_crop);     % 转为灰度图
    
    % Determine how many zero values in the image
    n = nnz(im_gray);                % 计算矩阵非零元素的数量
    m = numel(im_gray);              % 计算矩阵大小
    
    if all(im_gray(:) == im_gray(1)) % 若全部像素相同则没有下棋
        disp('Empty board');         % 该位置为无棋
    else
        white_pixel = (n/m) * 100;   % 根据非零元素数量判断白色像素的占比
        
        if white_pixel > 80
            disp('white piece');     % 该位置为白棋
        else
            disp('black piece');     % 该位置为黑棋
        end
    end
    
    % Display the croped image 显示棋子的灰度图
    imshow(im_gray)

end